<?php

namespace App\Http\Controllers;

use App\Common\Utils\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class ExternalController extends Controller
{
    /** @var \App\Services\ExternalService $externalService */
    private $externalService;

    public function __construct()
    {
        parent::__construct();
        $this->middleware('request.logger');
        // 关闭调试栏输出
        if (class_exists('\Debugbar')) {
            \Debugbar::disable();
        }
        $this->externalService = app('externalService');
    }

    /**
     * 获取活动列表
     */
    public function getActivities(Request $request)
    {
        try
        {
            $requestData = json_decode($request->getContent(), TRUE );
            $result = $this->externalService->getActivities($requestData);
            return JsonResponse::get($result['data'],TRUE,$result['total'],$result['per_page']);
        }
        catch(\Exception $e)
        {
            return $this->error($e);
        }
    }
}
